﻿using BLL;
using BLL.Access;
//********************************************************************************//
//创建日期：<创建日期，2016-4-14>
//页面创建：<孙雪婷，sunxueting@shanghai3h.com>
//后台逻辑：
//功能说明：立成财务接口
//********************************************************************************//
using System;
using System.Data;
using System.Web.UI;

namespace Web.Pages.YongShui._6.ZhangWuGL
{
    public partial class LiChengCWJK : BasePage
    {

        #region 属性
        private DataTable dtLiChengSJ
        {
            get
            {
                return ViewState["dtLiChengSJ"] as DataTable;
            }
            set
            {
                ViewState["dtLiChengSJ"] = value;
            }
        }

        #endregion

        #region 变量
       
        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _spHelper = new SpHelper();
        /// <summary>
        /// 日志操作类
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();
        #endregion

        #region 事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }

        /// <summary>
        /// 生成数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnShengChengSJ_Click(object sender, EventArgs e)
        {
            LoadData();
        }

        /// <summary>
        /// 导入地下水数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDaoRuDXSSJ_Click(object sender, EventArgs e)
        {
            string result = "";
            //_spHelper.P_YS_ZW_DIXIASCWJK(out result);
            if (result!="") 
            { 
                //导入成功！
            }
        }

        /// <summary>
        /// 导入水资源数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDaoRuSZYSJ_Click(object sender, EventArgs e)
        {
            string result = "";
            //_spHelper.P_YS_ZW_SHUIZIYCWJE(out result);
            if (result != "")
            {
                //导入成功！
            }
        }

        /// <summary>
        /// 导入到立成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDaoRuDLC_Click(object sender, EventArgs e)
        {
            string zwny = txtZhangWuNY.Text;
            //_spHelper.P_YS_ZW_DAOCHULISJK(zwny);
            
        }

        /// <summary>
        /// 绑定空表头
        /// </summary>
        protected override void Render(HtmlTextWriter sender)
        {
            base.Render(sender);
        }
        #endregion

        #region 方法

        /// <summary>
        /// 页面加载
        /// </summary>
        private void InitData()
        {
            int zwym = BusinessTool.GetZWYM();
            txtZhangWuNY.Text = zwym.ToString();
           // LoadData();
        }

        /// <summary>
        /// 数据加载
        /// </summary>
        private void LoadData() 
        {
            int i_zwym = Convert.ToInt32(txtZhangWuNY.Text);
            this.dtLiChengSJ = _spHelper.P_YS_ZW_LICHENGCWRJJK(i_zwym / 100, i_zwym % 100).Tables[0];
            this.gvPingZhengXX.DataSource = this.dtLiChengSJ;
            this.gvPingZhengXX.DataBind();

            //this.gvPingZhengMX.DataSource = this.dtLiChengSJ;
            //this.gvPingZhengMX.DataBind();
        }
        #endregion
        /// <summary>
        /// 前台表格行改变事件回调方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            int index = Convert.ToInt32(this.hdCollection.Get("index"));
            int bh = Convert.ToInt32(this.dtLiChengSJ.Rows[index]["BIANHAO"]);
            string name = this.dtLiChengSJ.Rows[index]["NAME"].ToString();
            if (e.Parameter == "pzmx")
            {
                e.Result = e.Parameter + "|0|" + bh + "|" + name;
            }
            
        }

        protected void gvPingZhengMX_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
        {
            int bh = Convert.ToInt32(this.hdCollection.Get("bh"));
            string name = this.hdCollection.Get("name").ToString();
            string ym = txtZhangWuNY.Text.ToString();
            string ym2 = ym.Substring(0, 4) + "-" + ym.Substring(4, 2);
            //DataTable dt_temp = _spHelper.P_YS_ZW_LCMX(ym2, bh,name).Tables[0];
            //gvPingZhengMX.DataSource = dt_temp;
            //gvPingZhengMX.DataBind();
        }
    }
}